<%@ page pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/base/taglibs.jsp"%>
<html>
	<head>
		<link href="${ctx}/css/main.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="${ctx}/js/xhEditor/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="${ctx}/js/xhEditor/xheditor-zh-cn.min.js"></script>
		<script type="text/javascript" src="${ctx}/js/My97DatePicker/WdatePicker.js"></script>
		<script language="javascript">
			var message = '${message}';
			if(message != ''){
				alert(message);
			}
			
			function doDelete(action,id){
				if(confirm('是否确认删除？')){
					location.href = "${ctx}/" + action + "?id=" + id ;
				}
			}
			
			function clickFile(action,id){
				location.href = "${ctx}/" + action + "?id=" + id;
			}
			
			function submitAction(action){
				document.manageForm.action = action ;
				document.manageForm.submit();
			}
			
			function init(){
				document.getElementById("colleageName").value = "";
				document.getElementById("colleageCategory").value = "";
				document.getElementById("colleageLevel").value = "";
				document.getElementById("colleageCreatedate").value = "";
				document.getElementById("introduce").value = "";
				document.getElementById("userId").value = "";
				document.getElementById("userName").value = "";
				document.getElementById("localFile").outerHTML = document.getElementById("localFile").outerHTML;
			}
			
			function saveAction(action) {
				document.getElementById("introduce").value = $('#introduce').val();
				if(document.getElementById("colleageName").value == '') {
					alert('请输入学校名称');
					return ;
				}
				if(document.getElementById("colleageCategory").value == '') {
					alert('请输入学校类别');
					return ;
				}
				if(document.getElementById("colleageLevel").value == '') {
					alert('请输入学校等级');
					return ;
				}
				if(document.getElementById("userId").value == '') {
					alert('请输入学校管理员');
					return ;
				}
				if(document.getElementById("colleageCreatedate").value == '') {
					alert('请输入学校创建时间');
					return ;
				}
				if(document.getElementById("introduce").value == '') {
					alert('请输入学校简介');
					return ;
				}
				submitAction(action);
			}
			
			function validateFileType() {
				fileName = manageForm.localFile.value;
				fileType = fileName.substr(fileName.lastIndexOf(".")).toLowerCase(); 
				if(fileType != '.jpg' && fileType != '.png' && fileType != '.jpeg' && fileType != '.gif' && fileType != '.bmp'){
					alert('图片文件类型错误，图片必须是以jpg,gif,jpeg,png,bmp为后缀文件');
					manageForm.localFile.outerHTML = manageForm.localFile.outerHTML;
					return false;
				}
			}
			
			var detail;
		
			function searchUserInfo() {
				if(!detail || detail.closed) {
					detail = window.open("about:blank", "user_choose", "status,scrollbars,resizable=no,left=190,top=150,width=480,height=380");
				}
				ownerForm.target = "user_choose";
				ownerForm.submit();
				detail.focus();
			}
		</script>
	</head>
	
	<body>
		<form name="ownerForm" id="ownerForm" method="post" action="searchProdOwner.ac"></form>
		<form method="post" action="" name="manageForm" ENCTYPE="multipart/form-data">
			<table border="0" cellspacing="1" cellpadding="3" align="center" width="100%">
				<tr>
					<td class="td11" align="left" colspan="4">
						<input type="button" name="search" value="保存" onClick="saveAction('saveColleageInfo.ac')">
						<c:if test="${!empty collegeInfo.id}">
							&nbsp;&nbsp;<input type="button" name="delete" value="删除" onClick="doDelete('deleteColleage.ac','${collegeInfo.id}')">
						</c:if>
						<c:if test="${empty collegeInfo.id}">
							&nbsp;&nbsp;<input type="button" name="reset" value="重置" onClick="init()">
						</c:if>
						&nbsp;&nbsp;<input type="button" name="back" value="返回" onClick="submitAction('backToColleageInfoSearch.ac')">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						学校名称  <span style="color:red;vertical-align:middle;">*</span>
					</td>
					<td width="30%" class="td2">
						<input type="hidden" name="id" value="${collegeInfo.id}">
						<input type="hidden" name="fileName" value="${collegeInfo.fileName}">
						<c:if test="${empty collegeInfo.id}">
							<input type="text" name="colleageName" size="32" value="${collegeInfo.colleageName}">
						</c:if>
						<c:if test="${!empty collegeInfo.id}">
							<input readonly="readonly" style="color:grey" type="text" name="colleageName" size="32" value="${collegeInfo.colleageName}">
						</c:if>
					</td>
					<td width="20%" class="td2">
						学校类别  <span style="color:red;vertical-align:middle;">*</span>
					</td>
					<td width="30%" class="td2">
						<select name="colleageCategory" id="colleageCategory" style="width:200px">
							<c:forEach var ="colleageCategory" items="${sessionScope.T_colleageCategoryList}">
								<c:if test="${collegeInfo.colleageCategory == colleageCategory.typeCode}">
									<option value="${colleageCategory.typeCode}" selected="selected">${colleageCategory.typeName}</option>
								</c:if>
								<c:if test="${collegeInfo.colleageCategory != colleageCategory.typeCode}">
									<option value="${colleageCategory.typeCode}">${colleageCategory.typeName}</option>
								</c:if>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						学校等级  <span style="color:red;vertical-align:middle;">*</span>
					</td>
					<td width="30%" class="td2">
						<select name="colleageLevel" id="colleageLevel" style="width:200px">
							<c:if test="${collegeInfo.colleageLevel == 1}">
								<option value="1" selected="selected">985</option>
								<option value="2" >211</option>
								<option value="3" >其他</option>
							</c:if>
							<c:if test="${collegeInfo.colleageLevel == 2}">
								<option value="1" >985</option>
								<option value="2" selected="selected">211</option>
								<option value="3" >其他</option>
							</c:if>
							<c:if test="${collegeInfo.colleageLevel == 3}">
								<option value="1" >985</option>
								<option value="2" >211</option>
								<option value="3" selected="selected">其他</option>
							</c:if>
							<c:if test="${empty collegeInfo.colleageLevel}">
								<option value="1" >985</option>
								<option value="2" >211</option>
								<option value="3" >其他</option>
							</c:if>
						</select>
					</td>
					<td width="20%" class="td2">
						学校管理员  <span style="color:red;vertical-align:middle;">*</span>
					</td>
					<td width="30%" class="td2">
						<input type="hidden" name="userId" value="${collegeInfo.userId}"/>
						<input readonly="readonly" type="text" name="userName" size="28" value="${collegeInfo.userName}">
						<img onclick="searchUserInfo()" src="${ctx}/images/index/search.gif" width="16" height="16" align="absmiddle">
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2">
						校徽图片
					</td>
					<td width="20%" class="td2" >
						<input type="file" name="localFile" size="24" value="" onchange="validateFileType();">
					</td>
					<td width="20%" class="td2">
						学校创建时间 <span style="color:red;vertical-align:middle;">*</span>
					</td>
					<td width="20%" class="td2">
						<input size="28" readonly="readonly" id="colleageCreatedate" type="text" name="colleageCreatedate" value="${collegeInfo.colleageCreatedate}"/>
						<img onclick="WdatePicker({el:'colleageCreatedate'})" src="${ctx}/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle">
					</td>
				</tr>
				<tr>
					<td width="10%" class="td2">  
						文件
					</td>
					<td width="30%" class="td2" colspan="3">
						<a href="javascript:clickFile('getColleageLogo.ac','${collegeInfo.id}');">${collegeInfo.fileName}</a>
					</td>
				</tr>
				<tr>
					<td width="20%" class="td2" colspan="4">
						学校简介  <span style="color:red;vertical-align:middle;">*</span>
					</td>
				</tr>
				<tr>
					<td width="100%" class="td2" colspan="4" align="center">
						<textarea id="introduce" name="introduce" class="xheditor {tools:'Cut,Copy,Paste,Pastetext,Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,SelectAll,Removeformat,Align,List,Outdent,Indent,Link,Unlink,|,Preview,Print,Fullscreen',skin:'vista',width:750,height:380}">
							${collegeInfo.introduce}
						</textarea>
					</td>
				</tr>
			</table>
		</form>
	</body>
</html>